package com.youcai.springboot_day03.dao;


import com.youcai.springboot_day03.entity.Department;
import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

@Repository
public class DepartmentDaoImpl {

    private static Map<Integer, Department> departmentMap = null;

    static {

        departmentMap = new HashMap<Integer, Department>();

        departmentMap.put(101,new Department(101,"教学部"));
        departmentMap.put(102,new Department(102,"后勤部"));
        departmentMap.put(103,new Department(103,"教研部"));
        departmentMap.put(104,new Department(104,"运营部"));
        departmentMap.put(105,new Department(105,"小卖部"));

    }

    //获得所有的部门信息
    public Collection<Department> getDepartment(){
        return departmentMap.values();
    }

    //通过id来查询部门
    public Department departmentByDno(Integer dno){
        return departmentMap.get(dno);
    }


}
